package org.zqy.service.impl;

import org.zqy.dao.UserDao;
import org.zqy.dao.impl.UserDaoImpl;
import org.zqy.domain.User;
import org.zqy.service.UserService;
import org.zqy.util.MD5Util;

/** 用户服务实现类 */
public class UserServiceImpl implements UserService {
	private UserDao userDao = new UserDaoImpl();

	@Override
	public boolean isRight(String uaccount, String password) {
		User u;
		String str = null;
		try {
			// 加密密码
			str = MD5Util.getMD5AddDESCode("schoolunionsite", password);
		} catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
		u = userDao.getUser(uaccount);
		if (u != null) {
			System.out.println("存在此用户");
			if (u.getUpassword().equals(str)) {
				return true;
			}
		}
		return false;
	}

	@Override
	public boolean addUser(User user) {
		return userDao.addUser(user);
	}

	@Override
	public boolean deleteUser(User user) {
		return userDao.deleteUser(user);
	}

	@Override
	public boolean updateUser(User user) {
		return userDao.updateUser(user);
	}
}
